package com.whfc.ms.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author xuguocheng
 * @desc 自定义WebMvcConfigurer
 * @date 2019-08-03
 */
@Configuration
public class CustomWebMvcConfigurer implements WebMvcConfigurer {

    @Autowired
    private LoginCheckInterceptor loginCheckInterceptor;

    @Autowired
    private RequestHeaderInterceptor requestHeaderInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //风潮登录验证
        registry.addInterceptor(loginCheckInterceptor)
                .addPathPatterns("/ms/api/**")
                .excludePathPatterns("/ms/api/third-login")
                .excludePathPatterns("/ms/api/sgitg-login")
                .excludePathPatterns("/ms/api/login")
                .excludePathPatterns("/ms/api/wxlogin")
                .excludePathPatterns("/ms/api/logout")
                .excludePathPatterns("/ms/api/ws/msg")
                .excludePathPatterns("/ms/api/**/anon/**");
        //请求头验证 orgId验证
        registry.addInterceptor(requestHeaderInterceptor)
                .addPathPatterns("/ms/api/esgcc/**")
                .excludePathPatterns("/ms/api/esgcc/sys/dept/list")
                .excludePathPatterns("/ms/api/**/anon/**");
    }
}
